// const promise = new Promise(resolve => { 2 , 1, 4 ,3,6
//     console.log(222);
//     resolve();
//   });
  
//   setTimeout(() => {console.log(333);}, 0);
  
//   promise.then(() => {console.log(444);});
  
//   setImmediate(() => {console.log(666);});
  
//   process.nextTick(() => {console.log(111);});


// process.nextTick(() => {
//     console.log('process.nextTick() 333');
//   })
  
//   setTimeout(() => {
//     console.log('setTimeout()  111');
//   }, 0)
  
//   setImmediate(() => {
//     console.log('setImmediate() 222');
//   })
  
//   console.log('全局代码执行完了 444');

process.nextTick(() => {console.log(111);});

setTimeout(() => {console.log(222);}, 0);
setImmediate(() => {console.log(333);});

const promise = Promise.resolve();

promise
  .then(() => {
    console.log(444);
    process.nextTick(() => {console.log(555);});
    setTimeout(() => {console.log(666);}, 0);
  })
  .catch(() => {console.log(777);})
  .then(() => {
    console.log(888);
    setImmediate(() => {console.log(999);});
  })
  .catch(() => {console.log(101010);})